var logic = {};

/**
 * 旋转
 * @param {type} a
 * @param {type} b
 * @param {type} c
 * @param {type} d
 * @returns {Array}
 */
logic.rotate = function(a, b, c, d) {
    var A = parseInt(b - d + c);
    var B = parseInt(c - a + d);
    return [A, B];
};
test = function(range){
    _.each(range, function(cell){
        cell.set('j', cell.get('j')+1);
    });
};
logic.init = function() {
    var view = app.get('scene').find('/layer/grid1');
    var data = {
        i: 10, j: 20,
        data: [
            {i: 0, j: 0, res: '01'},
            {i: 1, j: 1, res: '02'},
            {i: 2, j: 2, res: '03'},
            {i: 3, j: 3, res: '04'},
            {i: 4, j: 4, res: '05'}
        ]
    };
    var model = gg.module('Grid').create(data);
    view.setModel(model);
    window.v = view;
    window.m = model;
    app.get('scene').find('/layer/grid2').setModel(model);
    window.range = m.range(0,0,1,10);
    /**
     window.render = function(obj) {
     //render
     var pic = [];
     var x = obj.get('i');
     var y = obj.get('j');
     for (var i = 1; i <= x; i++) {
     var temp = [];
     for (var j = 1; j <= y; j++) {
     var cell = obj.getCell(i, j);
     if (cell)
     temp.push(cell.get('type'));
     else
     temp.push('0');
     }
     pic.push(temp.join(','));
     }
     console.log(pic.join('\n'));
     };
     */
}


module.exports = logic;